package cn.chenhao.basic.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 配置类
 *  在这里你就可以配置你定义的拦截器，写你的黑名单，白名单
 *
 */
@Configuration// 配置类的专用注解
public class WebConfigurer implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")// 拦截地址（拦截所有）
                .excludePathPatterns("/login/**")// 放行登录页面
                .excludePathPatterns("/notify/**")
                .excludePathPatterns("/user/register/**")// 放行注册页面
                .excludePathPatterns("/verifycode/**")// 放行验证码发送
                .excludePathPatterns("/fastDfs")// 放行静态资源
                .excludePathPatterns("/shop/settlement/**")
                .excludePathPatterns("/swagger-resources/**","/webjars/**","/v2/**","/swagger-ui.html/**");// 放行swagger接口测试
    }
}
